function setUp(){
	
	PicBoard.selectedImage = { id: '', name: '' };

	// Swap the a tag with a doubleclick action
	$('.userItem').each(function(i, e){
		$(this).addClass('imageParent');
		$(this).find('img').unwrap();
		$(this).bind('dblclick', function(){
			window.location = $(this).children('img').attr('src');
		});
	});
	
	$('.userItem').bind('click', function(){
		if($(this).hasClass('userItem')){
			id = $(this).find('img').attr('id').match(/img_(\d+)$/);
			name = $(this).find('p.imageName').text();
		} else if($(this).hasClass('userImageIcon')){
			id = $(this).attr('id').match(/img_(\d+)$/);
			name = $(this).find('p.imageName').text();
		} else {
			id = $(this).find('img').attr('id').match(/img_(\d+)$/);
			name = $(this).find('p.imageName').text();
		}
		
		if(id[1] == PicBoard.selectedImage.id){
			PicBoard.selectedImage = { id: '', name: '' };	
			$('#nameSelected').text("None");
		} else {
			$('#nameSelected').text(name);
			PicBoard.selectedImage = { id: id[1], name: name };	
		}	
	});
	
	$('#PBDeleteImage').bind('click', function(){
		if(PicBoard.selectedImage.id != ""){
			var confirmDialog = confirm( $('#deleteConfirm').val() );
			
			if(confirmDialog){
				$.post(PicBoard.baseURL + 'rsrc.php?req=deleteImage', $.param(PicBoard.selectedImage), function(data){
					//console.dir(data);
					if(data.statusCode == 200){
						window.location = window.location;
					} else {
						jQuery.facebox(data.message);
					}
				}, 'json' );
			
			}
		}
	});
	
	$('#delete_imageset').bind('click', function(){
		PicBoard.getTranslations(['lang_245_deleteImagesetConfirm'], function(data){
		
			var qs = window.location.search;
			// Get the id from the request URL
			var id = qs.match(/\?.*?id=(\w+)/);

			var confirmDialog = confirm(data.payload.lang_245_deleteImagesetConfirm);
			
			if(confirmDialog){
				$.post(PicBoard.baseURL + 'rsrc.php?req=deleteImageSet', { id: id[1] }, function(data){
					if(data.statusCode == 200){
						window.location = "home";
					} else {
						jQuery.facebox(data.message);
					}
					
				}, 'json');
			}
		})
	});
}




PicBoard.addLoadEvent( "setUp()" );